#include <iostream>

using namespace std;

int min(int a,int b,int c,int d);

int main( )
{
    int i=1,j=1,k=1,m=1,n=1;
    int a[6000]={1,1}; 

    for(n=2;n<=5842;n++)
    {
        int t1,t2,t3,t4;
        t1=a[i]*2;
        t2=a[j]*3;
        t3=a[k]*5;
        t4=a[m]*7;
        a[n]=min(t1,t2,t3,t4);
        if(a[n]==t1) i++;
        if(a[n]==t2) j++;
        if(a[n]==t3) k++;
        if(a[n]==t4) m++;
    }

    cin>>n;
    cout<<a[n]<<endl;

    cin>>n;
    return 0;
}

int min(int a,int b, int c, int d)
{
    a=a>b?b:a;
    c=c>d?d:c;
    a=a>c?c:a;

    return a;
}